#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project ：zhcx-service-test 
@File    ：initialize_strategy_service.py
@Author  ：关依林
@Date    ：2023/7/17 23:28 
'''
import os

from testcases.ProductGrading_Strategy.ProductLibrary.baseAPI import *
from utils.mysqlUtils.db_utils import DB
from common.dir_config import ConfigHandler
from utils.readFileUtils.yamlControl import GetYamlData
from testcases.ProductGrading_Strategy.public_dispatch_way import *
from utils.logging_tool.log_control import *


class PolicyConditionMethod:

    def StrategyDataVerify(self):
        """
        1.先获取产品策略规则
        2.依据Listing分级思路细分模板
        3.获取产品表ID最大最小值
        4.通过主键ID进行分页查询进行过滤
        5.获取策略数据验证数据是否一致
        """
        statTime = time.time()
        strategyId = 27
        # 获取产品策略规则
        productStrategyRule = GetStrategyRule(strategyId)
        # 规则细分模板
        strategyRule,strategyRuleValue = StrategyRulePack(productStrategyRule)
        # 数据过滤逻辑处理
        strategyData = ProductDataFiltering(strategyRule, strategyRuleValue, productStrategyRule)
        # 获取策略服务数据结果
        serviceData = GetStrategyResult(strategyId)
        # 数据校验
        exceptionData = set(strategyData) - set(serviceData)

        endTime = time.time()
        elapsedTime = round(endTime - statTime, 2)
        print(f"执行时间为：{elapsedTime}")

        return exceptionData

if __name__ == '__main__':
    print(PolicyConditionMethod().StrategyDataVerify())